import { ref,watchEffect,  } from "vue";
import { useRoute } from "vue-router";
import { getTopCategoryAPI } from "@/apis/category";


export function useCategory() {
    const categoryData = ref({});
    const route = useRoute();

    const getCategory = async () => {
        const res = await getTopCategoryAPI(route.params.id);
        categoryData.value = res.result;
    };

    // onMounted(()=>{
    //     getCategory()
    // })
    watchEffect(() => {
        getCategory();
    });

    return { categoryData };
}